package iut.acy.cut4u.DAO;

import iut.acy.cut4u.model.Employe;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;


public class EmployeDAO extends EntiteDAO {

	public static EmployeDAO instance;
	
	public EmployeDAO()
	{
		super();
	}
	
	public static EmployeDAO getInstance(){
		if(EmployeDAO.instance == null){
			EmployeDAO.instance = new EmployeDAO();
        }
        return instance;
	}
	
	@Override
	public int update(Object o) throws SQLException {
		
		try{
			if(o instanceof Employe){
				Employe e = (Employe) o;
				String requete = "Update employe set nome=?, prenome= ?, adressee=?, cpe=?, villee=?, statute=?, categoriee=?";
				Connection cnx = this.db.getConnexion();
				PreparedStatement stmt = cnx.prepareStatement(requete);
				stmt.setString(1 , e.getNom());
				stmt.setString(2, e.getPrenom());
				stmt.setString(3, e.getAdresse());
				stmt.setString(4, e.getCodePostal());
				stmt.setString(5, e.getVille());
				stmt.setString(6, e.getStatut().toString());
				stmt.setString(7, e.getCategorie().toString());
				
				
				
			}
		}
		catch(SQLException e){
			
		}
		return 0;
	}

	@Override
	public int delete(Object o, boolean enCascade) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(Object o) {
		// TODO Auto-generated method stub
		return 0;
	}

}
